package com.yxinsur.imc.web.controller.business;

import java.util.List;

import com.yxinsur.imc.business.domain.ImcSupplierPersistencyDetail;
import com.yxinsur.imc.business.form.ImcSupplierPersistencyDetailForm;
import com.yxinsur.imc.business.service.IImcSupplierPersistencyDetailService;
import com.yxinsur.imc.business.vo.SupplierPersistencyDetailVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yxinsur.imc.common.annotation.Log;
import com.yxinsur.imc.common.core.controller.BaseController;
import com.yxinsur.imc.common.core.domain.AjaxResult;
import com.yxinsur.imc.common.enums.BusinessType;
import com.yxinsur.imc.common.utils.poi.ExcelUtil;
import com.yxinsur.imc.common.core.page.TableDataInfo;

/**
 * 供应商继续率子Controller
 *
 * @author imc
 * @date 2021-09-23
 */
@Api(value="保险公司继续率详情配置",tags={"保险公司继续率详情配置"})
@RestController
@RequestMapping("/business/persistency/detail")
public class ImcSupplierPersistencyDetailController extends BaseController {
    @Autowired
    private IImcSupplierPersistencyDetailService imcSupplierPersistencyDetailService;

    /**
     * 查询供应商继续率子列表
     */
    @ApiOperation("查询保险公司继续率详情列表")
    @GetMapping("/list")
    public TableDataInfo list(ImcSupplierPersistencyDetailForm imcSupplierPersistencyDetail) {
        List<SupplierPersistencyDetailVo> list = imcSupplierPersistencyDetailService.selectDetailByPersistency(imcSupplierPersistencyDetail);
        return getDataTable(list);
    }

    /**
     * 导出供应商继续率子列表
     */
    @PreAuthorize("@ss.hasPermi('system:detail:export')")
    @Log(title = "供应商继续率子", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ImcSupplierPersistencyDetailForm imcSupplierPersistencyDetail) {
        List<ImcSupplierPersistencyDetail> list = imcSupplierPersistencyDetailService.selectImcSupplierPersistencyDetailList(imcSupplierPersistencyDetail);
        ExcelUtil<ImcSupplierPersistencyDetail> util = new ExcelUtil<ImcSupplierPersistencyDetail>(ImcSupplierPersistencyDetail.class);
        return util.exportExcel(list, "detail");
    }

    /**
     * 获取供应商继续率子详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:detail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return AjaxResult.success(imcSupplierPersistencyDetailService.selectImcSupplierPersistencyDetailById(id));
    }

    /**
     * 新增供应商继续率子
     */
    @PreAuthorize("@ss.hasPermi('system:detail:add')")
    @Log(title = "供应商继续率子", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ImcSupplierPersistencyDetail imcSupplierPersistencyDetail) {
        return toAjax(imcSupplierPersistencyDetailService.insertImcSupplierPersistencyDetail(imcSupplierPersistencyDetail));
    }

    /**
     * 修改供应商继续率子
     */
    @ApiOperation("修改保险公司继续率")
    @Log(title = "修改保险公司继续率", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ImcSupplierPersistencyDetailForm imcSupplierPersistencyDetail) {
        return toAjax(imcSupplierPersistencyDetailService.updateImcSupplierPersistencyDetail(imcSupplierPersistencyDetail));
    }

    /**
     * 删除供应商继续率子
     */
    @PreAuthorize("@ss.hasPermi('system:detail:remove')")
    @Log(title = "供应商继续率子", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(imcSupplierPersistencyDetailService.deleteImcSupplierPersistencyDetailByIds(ids));
    }
}
